package com.lmk.feign;


import com.lmk.domain.Product;
import com.lmk.query.ProductQuery;
import com.lmk.result.JSONResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@FeignClient(name = "service-product",fallbackFactory = ProductServiceFallbackFactory.class)
public interface ProductService {
    /**
     * 保存和修改公用的
     */
    @RequestMapping(value="/product/save",method= RequestMethod.POST)
    JSONResult saveOrUpdate(@RequestBody Product product);

    /**
     * 删除对象
     */
    @RequestMapping(value="/product/{id}",method=RequestMethod.DELETE)
    public JSONResult delete(@PathVariable("id") Long id);

    /**
     * 获取对象
     */
    @RequestMapping(value = "/product/{id}",method = RequestMethod.GET)
    public JSONResult get(@PathVariable("id")Long id);


    /**
     * 查询所有对象
     */
    @RequestMapping(value = "/product/list",method = RequestMethod.GET)
    public JSONResult list();

    /**
     * 带条件分页查询数据
     */
    @RequestMapping(value = "/product/pagelist",method = RequestMethod.POST)
    public JSONResult page(@RequestBody ProductQuery query);

    @RequestMapping(value = "/product/{productname}",method = RequestMethod.GET)
    public Product getbyname(@PathVariable("productname")String productname);
}
